<?php

class Form_FriendLink extends Zend_Form
{

    public function init()
    {
    	$id = new Zend_Form_Element_Hidden("id");
        $id->setValue(0);
        $id->setRequired(true);
        $idValidator = new Zend_Validate_Int();
        $id->addValidator($idValidator);
        $this->addElement($id, "id");
        
        
        $name = new Zend_Form_Element_Text("name");
        $name->setLabel("友情链接名称: ");
        $name->setRequired(true);
        $this->addElement($name, "name");
        
        
        $url = new Zend_Form_Element_Text("url");
        $url->setLabel("指向URL: ");
        $this->addElement($url, "url");
        
        $image = new Zend_Form_Element_File("image");
        $image->setLabel("图片: ")->setRequired(true)
        	->setDestination(APPLICATION_PATH . "/../public/images/friendlink/");
        	
        $imageFilter = new Zend_Filter_File_Rename(md5(microtime()) . ".jpg");
        
        $image->addFilter($imageFilter);
        	
        $imageValidator = new Zend_Validate_File_Extension("jpg");
        $image->addValidator($imageValidator);
        $this->addElement($image, "image");
        
        
        $order = new Zend_Form_Element_Text("display_order");
        $order->setLabel("显示顺序: ");
        $this->addElement($order, "display_order");
        
        
        $enabled = new Zend_Form_Element_Radio("enabled");
        $enabled->setLabel("是否生效: ");
        $enabled->addMultiOption(1, "是");
        $enabled->addMultiOption(0, "否");
        $enabled->setValue(1);
        $this->addElement($enabled, "enabled");
        
        
        
        $submit = new Zend_Form_Element_Submit("submit");
        $this->addElement($submit, "submit");
    }


}

